package com.cihon.controller;

import com.cihon.model.Param;
import com.cihon.validator.ValidateField;
import com.cihon.validator.ValidateGroup;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/test")
public class TestController {

    @ValidateGroup(fields = {@ValidateField(index = 0, notNull = true, showName = "字段a")})
    @RequestMapping(value = "/a")
    public Object test(String a) {
        return a;
    }
    @ValidateGroup(fields = {
            @ValidateField(index = 0,filedName = "value", notNull = true, showName = "value 属性value")
    })
    @RequestMapping(value = "/param", method = RequestMethod.POST)
    public Object param(@RequestBody Param param){
        return param;
    }

    @RequestMapping(value = "/test")
    public Object doThing(String test) throws Exception {
        throw new NullPointerException("故意抛出的错误");
    }

}
